package com.qfedu.aunt.commons.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qfedu.aunt.commons.exception.BusinessException;
import com.qfedu.aunt.commons.pojo.WorkType;
import com.qfedu.aunt.commons.mapper.WorkTypeMapper;
import com.qfedu.aunt.commons.result.ResponseCode;
import com.qfedu.aunt.commons.service.WorkTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 工作类型表 服务实现类
 * </p>
 *
 * @author xiaobobo
 * @since 2022-10-26
 */
@Service
public class WorkTypeServiceImpl extends ServiceImpl<WorkTypeMapper, WorkType> implements WorkTypeService {

    @Autowired
    private WorkTypeMapper workTypeMapper;

    @Override
    public List<WorkType> findWorkTypeByLevel(Integer level) throws Exception{
        if(null==level){
            throw new BusinessException(ResponseCode.PARAMETER_ERROR.getCode(),
                    ResponseCode.PARAMETER_ERROR.getMessage());
        }
        //这个过后说明参数合法
        QueryWrapper<WorkType> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("level",level);
       return  workTypeMapper.selectList(queryWrapper);
    }
}
